home *** CD-ROM | disk | FTP | other *** search
/ NeXT Enterprise Objects Framework 1.1 / NeXT Enterprise Objects Framework 1.1.iso / NextDeveloper / Examples / EnterpriseObjects / QueryByExample / QBEPalette / TableMagic.m < prev   
Encoding:
Text File  |  1995-01-25  |  1.1 KB  |  44 lines

  1. // TableMagic - some useful methods for dealing with tableViews tied to controllers.
  2.  
  3. #import "TableMagic.h"
  4.  
  5. @implementation NXTableView (tableMagic)
  6. + keyTableView
  7. {
  8.     id view = [[NXApp mainWindow] firstResponder];
  9.     return ([view isKindOf:[NXTableView class]]) ? view : nil;
  10. }
  11.  
  12. - (EOController *)eoController
  13. {
  14.     id assoc = [self delegate];
  15.     if ([assoc isKindOfClass:[EOAssociation class]])
  16.         return [assoc controller];
  17.     else
  18.         return nil;
  19. }
  20.  
  21. - (NSString *)associationKeyForColumn: (unsigned int)colNum
  22. {
  23.     id vector = [self columnAt:colNum];
  24.     id assoc  = [vector identifier];
  25.     return ([assoc isKindOfClass:[EOAssociation class]]) ? [assoc key] : nil;
  26. }
  27.  
  28. - (NSArray *)associationKeysForSelectedColumns
  29. {
  30.     int numselected = [self selectedColumnCount];
  31.     int colNum;
  32.     NSMutableArray *keys;
  33.  
  34.     keys = [NSMutableArray arrayWithCapacity:numselected];
  35.  
  36.     colNum = NX_NoIndex;
  37.     while ((colNum = [self selectedColumnAfter:colNum])!=NX_NoIndex) {
  38.         [keys addObject:[self associationKeyForColumn:colNum]];
  39.     }
  40.  
  41.     return keys;
  42. }
  43. @end
  44.